<?include_once('conn.php');?>
<html>
<head>
<?include_once('inc_head.php');?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?
$act=$_GET['act'];
$path='../uploads/news/';
#/////////////////////////修改/////////////////////
if($act=='editok') {	
	$id=$_POST['id'];
	$title=rq('title');
	$series=intval($_POST['smallname']);

	$cmd="update ".TABLE_C."vote_question set title='$title',series=$series where id=$id";
	if(mysql_query($cmd) or die(mysql_error())){
	gourl('修改成功！',$cururl);	
	}
	exit;
}
?>

</head>
<body >
<? local("内容编辑");?>
<div id="intro">

<?
$id=intval($_GET['id']);
$cmd="select * from ".TABLE_C."vote_question where id=$id";
$rs=mysql_query($cmd);
$data=mysql_fetch_assoc($rs);
?>
<form name="formnewsedit" method="post" action="?act=editok">
	<input type="hidden" name="id" value="<?echo $data['id']?>">
	<table class="table_form" width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
		<td width="100"> 标题 </td>
		<td> <input name="title" type="text" class=":required form-control" id="title" size="70" value="<?echo $data['title']?>"> </td>
	</tr>
	
	<tr>
		<td> 更改类别 </td>
		<td>
				<?
				/*
					$cmd1="select * from ".TABLE_C."vote_series order by id";
					$rs1=mysql_query($cmd1) or die(mysql_error());
					while($row1=mysql_fetch_assoc($rs1)){
						if($row1['id']==$data['series']){
							echo '<option selected value='.$row1[id].'> '.$row1[name].'</option> ';
						}else{
							echo '<option value='.$row1[id].'>'.$row1[name].'</option> ';
						}
					}
					mysql_free_result($rs1);
					*/

					echo '<select name="smallname" id="smallname">';
					echo '<option  value="0" style="background:yellow;">全部</option>';
					$cmd1="select * from ".TABLE_C."vote_series where forid=0 order by id";
					$rs1=mysql_query($cmd1) or die(mysql_error());
					while($row1=mysql_fetch_assoc($rs1)){
						echo '<optgroup  label='.$row1[name].'>';
						////////////////2级循环////////////////////////
						$cmd2="select * from ".TABLE_C."vote_series where forid={$row1[id]} order by id";
						$rs2=mysql_query($cmd2) or die(mysql_error());
						while($row2=mysql_fetch_assoc($rs2)){
							if($row2['id']==$data['series']){
								echo '<option selected value='.$row2[id].'>&nbsp;&nbsp;|—'.$row2[name].'</option>';
							}else{
								echo '<option value='.$row2[id].'>&nbsp;&nbsp;|—'.$row2[name].'</option>';
							}
						}
						mysql_free_result($rs2);
						echo '</optgroup>';
					}
					mysql_free_result($rs1);
					echo '</select>';
				?>

		</td>
	</tr>
	<tr>
		<td> &nbsp; </td>
		<td> <button type="submit" class="btn btn-primary">保存</button> </td>
	</tr>
	</table>
</form>
</div>
<?include('inc_foot.php');?>
</body>
</html>